package  com.makinolo.rlvforge.tacx.data
{
	import com.makinolo.rlvforge.tacx.utils.StringUtils;
	
	import flash.utils.ByteArray;
	
public class CourseInfo implements Persistent
{
	public static const RECORD_SIZE:int = 596;
	
	private static const SEGMENTNAME_LEN:int = 32;
	private static const TEXTFILE_LEN:int = 260;	
	
	private var start:Number; //	Start of route section (time (s) or distance (m), depending on program type)
	private var end:Number;   //	End of route section (time (s) or distance (m), depending on program type)
	private var CourseSegmentName:String; // 66 char string (32 + 0 terminator) in Unicode		
	private var TextFile:String ; //	522	char string
	
/*	public CourseInfo(LEDataInputStream dis)
	{
		this.start = dis.readFloat();
		this.end = dis.readFloat();
		CourseSegmentName = dis.readString(SEGMENTNAME_LEN); 
		TextFile = dis.readString(TEXTFILE_LEN);		
	}
*/	
	public function CourseInfo(start:Number, end:Number, courseSegmentName:String , textFile:String )
	{		
		this.start = start;
		this.end = end;
		setCourseSegmentName(courseSegmentName);
		setTextFile(textFile);
	}
	
	public function getCourseSegmentName():String 
	{
		return CourseSegmentName;
	}
	public function setCourseSegmentName(courseSegmentName:String ):void
	{		
		CourseSegmentName = StringUtils.stuff(courseSegmentName, 0,SEGMENTNAME_LEN);
	}
	public function compareCourseSegmentName(name:String):Boolean
	{
		return CourseSegmentName == StringUtils.stuff(name, 0,SEGMENTNAME_LEN);
	}
	public function getEnd():Number
	{
		return end;
	}
	public function setEnd(end:Number):void
	{
		this.end = end;
	}
	public function getStart():Number
	{
		return start;
	}
	public function setStart(start:Number):void
	{
		this.start = start;
	}
	public function getTextFile():String 
	{
		return TextFile;
	}
	public function setTextFile(textFile:String ):void
	{
		if (textFile==null)
			textFile = "";
		TextFile = StringUtils.stuff(textFile, 0, TEXTFILE_LEN);		
	}	
	
	public function persist(dos:ByteArray):void
	{
		dos.writeFloat(start);
		dos.writeFloat(end);
		dos.writeBytes(StringUtils.StringToTacxBytes(CourseSegmentName));		
		dos.writeBytes(StringUtils.StringToTacxBytes(TextFile));		
	}
}
}